package com.colorlight.cloud.common.utils;


import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

/**
 * @author Demon
 * @description aes加密
 * @date 9/4/2024  上午9:16
 */
public class AesUtil {
	
	/**
	 *  不加盐加密
	 * @param source 需要加密的密文
	 * @return 加密后
	 * @author Demon
	 * @date 9/4/2024/上午10:05
	 **/
	public static byte[] encrypt(String source, String aesKey) throws Exception {
		SecretKey key = new SecretKeySpec(aesKey.getBytes(), "AES");
		Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
		cipher.init(Cipher.ENCRYPT_MODE, key);
		return cipher.doFinal(source.getBytes());
	}
	
}
